package demo.component.controller;

import demo.component.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@Controller
public class StudentController {
    //构造方法注入
    private StudentService studentService;
    //这里不添加Autowired也可以正常使用
    //仅限于类中只有一个构造方法的时候
    @Autowired
    public StudentController(StudentService studentService) {
        this.studentService = studentService;
    }

    public void sayHi(){
        studentService.sayHi();
    }
}
